package validator

import "payment/model"

type PayOutValidator struct {
	AppId      model.AppId   `form:"app_id"`
	AppOrderId string        `form:"app_order_id"`
	PayType    model.PayType `form:"app_order_id"`
	//PayChannel model.PayChannel `form:"pay_channel"`
	Amount   int64  `form:"amount"`
	UserId   string `form:"uid"`
	UserName string `form:"user_name"`
	Phone    string `form:"phone"`
	Email    string `form:"email"`
	BankCard string `form:"bank_card"`
	Paytm    string `form:"paytm"`
	Address  string `form:"address"`
}

func (rs *PayOutValidator) Valid() (res bool, msg string) {
	if rs.AppId == "" {
		return false, "app_id is empty"
	}
	if rs.AppOrderId == "" {
		return false, "app_order_id is empty"
	}
	if rs.Amount == 0 {
		return false, "amount is empty"
	}
	if rs.UserId == "" {
		return false, "uid is empty"
	}
	if rs.UserName == "" {
		return false, "user_name is empty"
	}
	if rs.Phone == "" {
		return false, "phone is empty"
	}
	if rs.PayType == model.PT_PayTm && rs.Paytm == "" {
		return false, "paytm is empty"
	}
	if rs.Email == "" {
		return false, "email is empty"
	}
	if rs.Address == "" {
		return false, "address is empty"
	}
	return true, ""
}
